#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <aura.h>
#include <auraplus.h>

struct _LockInfo {
    Aura_Char        m_szName[AURA_MAX_DIR];
    Aura_Int32        m_iSemId;
    Aura_ThreadId     m_iOwerTid;
    Aura_UInt32       m_uOwerCount;
};


Aura_ECode CreateAnonymDir(/*out*/char *pDirName)
{
    Aura_ProcessId iPid;
    int ret;
    Aura_UInt32 i = 0;

    assert(pDirName);

    iPid = 1;//AuraProcess_GetCurrentId();

    do{
        sprintf(pDirName, "/tmp/anon%d_%d", (int)iPid, i++);
        ret = mkdir(pDirName, 0x777);
        if(0 == ret) {
            //PTRACE("Create annoymous dir:%s.\n", pDirName);
            return AURA_NOERROR;
        }
    }while((-1 == ret)&&(EEXIST == errno)&&(0 < i));

    PERROR("Error:Create annoymous dir failed! errno:%d.\
    file:%s. line:%d. \n",
    errno, __FILE__, __LINE__);
    return AURA_E_INVALID_OPERATION;

}

Aura_ECode _CreateLock(/* [out] */ Aura_Handle * phLock)
{

    return AURA_NOERROR;

}


Aura_ECode _Lock(Aura_Handle hLock)
{

    return AURA_NOERROR;
}

Aura_ECode _Unlock(
        /* [in] */ Aura_Handle hLock)
{

    return AURA_NOERROR;
}

Aura_ECode _DestroyLock(
        /* [in] */ Aura_Handle hLock)
{

    return AURA_NOERROR;
}
